<template>
	<uni-popup ref="popup">
		<view class="bg-white radius padding-sm" style="width: 500rpx;">
			<view class=" flex justify-between">
				<view class="text-title"></view>
				<view class="cuIcon-close" @click="close()"></view>
			</view>

			<view class="padding-sm">

				<!-- 提示 -->
				<view class="text-pink  text-bold flex justify-center margin-top-lg">
					注意:打开房间门后,后将开始计时
				</view>

				<view>

					<view class="margin-top-lg ">
						<button class="cu-btn block round bg-pink lg shadow" @click="openDoor(1)">
							<text class="cuIcon-lock margin-right-sm"></text> 1 打开大厅门
						</button>
					</view>


					<view class="margin-top-lg ">
						<button class="cu-btn block round bg-pink lg shadow" @click="openDoor(2)">
							<text class="cuIcon-lock margin-right-sm"></text> 2 打开房间门
						</button>
					</view>


					<view class="margin-top-lg ">
						<view class="text-gray text-sm  flex justify-center ">
							提示:如果开门没反应,请联系商家
						</view>
						<button class="cu-btn block round line-pink  shadow" @click="openDoor(2)">
							<text class="cuIcon-dianhua margin-right-sm"></text> 联系商家开门
						</button>
					</view>
				</view>

				<!-- 提示 -->
				<view class="text-gray text-sm text-bold flex justify-center margin-top-lg">
					提示:如果提前到达 可在大厅休息
				</view>
			</view>

		</view>

	</uni-popup>
</template>

<script>
	import {
		openDoor
	} from "@/api/shop/device/SysShopDeviceManagementApi"
	export default {
		name: "selectStorePopup",
		data() {
			return {
				from: {
					id: null,
					type: null,
				}
			};
		},
		onShow() {

		},
		methods: {
			open(data) {
				this.$refs.popup.open()
				console.log(data);
				this.from.id = data.id


			},
			close() {
				this.$refs.popup.close()
			},



			async openDoor(type) {
				this.from.type = type
				let {
					msg,
					code
				} = await openDoor(this.from)
				if (code == 0) {
					uni.showModal({
						title: '开门成功',
						content: (type == 1 ? '大厅门' : '房间门') + "已打开,如果还是打不开,请联系商家",
						showCancel: false,
						success: function(res) {
							if (res.confirm) {

							}
						}
					});
				}

			},


		}
	}
</script>

<style>
	.toTop {}
</style>